﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace LingDong.PictureKeywords
{
    public class DownloadedPictures
    {
        public static void Load(string indexFile)
        {
            if (loaded)
                return;

            pictureIndex = new Dictionary<string, string>();
            using (StreamReader sr = new StreamReader(indexFile))
            {
                string line;
                while (!sr.EndOfStream)
                {
                    line = sr.ReadLine();

                    string[] terms = line.Split();
                    pictureIndex[terms[1]] = terms[2];
                }
            }
            loaded = true;
        }

        public static bool IsPictureDownload(string picSrc)
        {
            return pictureIndex.ContainsKey(picSrc);
        }

        private static Dictionary<string, string> pictureIndex;
        private static bool loaded = false;
    }
}
